<template>
  <div style="background: #fff">
    <div class="title">
     <div>{{title}}</div>
    </div>
    <div style="padding: 1.875rem">
      <el-form :inline="true">
        <el-form-item label="">
          <el-input
            v-model="query.name"
            placeholder="订单号"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="选择订单状态">
          <el-select v-model="query.pay_status" placeholder="请选择"  clearable>
            <el-option
              v-for="item in pay_status"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
         <el-form-item label="选择城市" v-if="type!=4">
          <el-select v-model="query.city_id" placeholder="请选择" @change="getArea" clearable>
            
            <el-option
              v-for="item in city"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="选择区县" v-if="type!=4">
          <el-select v-model="query.area_id" placeholder="请选择" clearable>
            <el-option
              v-for="item in area"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        
    
        <el-form-item>
          <el-button type="success" @click="getData(true)">查询</el-button>
          <el-button @click="reset">重置</el-button>
          <!-- <el-button type="primary" @click="showEdit(-1)">添加</el-button> -->
        </el-form-item>
      </el-form>
    </div>
    <el-table :data="data" stripe style="width: 100%" >
      <el-table-column prop="id" label="id"></el-table-column>
       <el-table-column label="商户">
        <template slot-scope="scope">
          {{scope.row.shop.name}}
        </template>
      </el-table-column>
      <el-table-column prop="order_sn" label="订单号"></el-table-column>
      <el-table-column prop="out_trade_no" label="微信支付流水号"></el-table-column>
       <el-table-column prop="city" label="城市" ></el-table-column>
       <el-table-column prop="area" label="区县"></el-table-column>
        <el-table-column prop="created_at"  label="消费时间"></el-table-column>
        <el-table-column prop="real_price" label="实收"></el-table-column>
          <el-table-column label="节省">
        <template slot-scope="scope">
          {{(scope.row.total_price)-(scope.row.real_price)}}
        </template>
      </el-table-column>
         <el-table-column prop="real_price" label="分账"></el-table-column>
       
      <!-- <el-table-column label="头像" >
          <template slot-scope="scope">
            <el-image
              :src="
                scope.row.icon +
                '?imageView2/1/w/50/h/50/format/webp/q/75|imageslim'
              "
              style="width:50px;height:50px"
              :preview-src-list="[scope.row.icon]"
            >
            </el-image>
          </template>
        </el-table-column> -->
       <el-table-column label="状态">
        <template slot-scope="scope">
          {{['待付款','已付款'][(scope.row.pay_status-1)]}}
        </template>
      </el-table-column>

       
   
     
      
     
      
      <!-- <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="small" @click="showEdit(scope.row.id)">查看详情</el-button>
          <el-button type="error" size="small" @click="del(scope.row)">删除</el-button>
        </template>
      </el-table-column> -->
    </el-table>
    <el-pagination
      v-if="data.length>0"
      background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pages.currentPage"
     
      :page-size="pages.per_page"
      layout="total,prev, pager, next"
      :total="pages.total"
      style="text-align: center"
    >
    </el-pagination>
   
  
    
  </div>
</template>

<script>
import mixin from "../../js/mixin";

export default {
  name: "homePage",
  mixins: [mixin],
  data() {
    return {
      is_check:false,
      is_page: true,
      api_url: "order",
      one: [],
      two:[],
      item: {},
      pay_status:[{
        id:1,
        name:'待付款'
      },{
        id:2,
        name:'已付款'
      }],
      query: {
         city_id:'',
        area_id:'',
      },
    };
  },
  components: {},
  mounted() {
   
  },
  created() {
    this.type = localStorage.getItem('admin_type')
    this.title = this.$route.meta.title
    this.init()
  },
  methods: {
    reset() {
      this.query = {}
      this.getData(true)
    },
    init(){
       this.getCity()
      this.getData()
      
    },
    
    
    showEdit(e) {
      let { href } = this.$router.resolve({
        name: "shopDetail",
        params: { id:e },
        query: {
         
        }
      });
      window.open(href, "_blank");
    },

    // getDocument() {
    //   this.global
    //     .httpRequest("document", { user_id: this.item.id })
    //     .then((res) => {
    //       this.document = res;
    //     });
    // },
   
  },
};
</script>

<style scoped>




</style>
